package com.swipemaster.dialogs;

import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

import com.swipemaster.R;
import com.swipemaster.common.Global;
import com.swipemaster.record.RecordId;

public class HelpDialog extends Dialog
{
	final TextView messageView;
	final Button okBtn;
	final CheckBox dontShowCheckBox;

	public HelpDialog(Activity activity, RecordId recordId)
	{
		super(activity);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.help_dialog);

		// Removes border of the dialog.
		getWindow().setBackgroundDrawableResource(android.R.color.transparent);
		getWindow().getAttributes().windowAnimations = R.style.DialogAnimationScale;

		messageView = (TextView) findViewById(R.id.help_dialog_message);
		messageView.setText(getHelpMessage(recordId));

		dontShowCheckBox = (CheckBox) findViewById(R.id.dont_show_again_check);

		okBtn = (Button) findViewById(R.id.help_dialog_start_btn);
		okBtn.setOnClickListener(new View.OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				if (dontShowCheckBox.isChecked())
				{
					Global.app.gameMode.hideHelp();
				}
				dismiss();
			}
		});
		Dialogs.ensureSize(findViewById(R.id.help_dialog_root_layout));
	}

	private String getHelpMessage(RecordId recordId)
	{
		if (recordId.getType() == RecordId.CHALLENGE)
		{
			return Global.app.getString(R.string.challenge_help_message);
		}
		if (recordId.getLevelIndex() == 0)
		{
			return Global.app.getString(R.string.first_help_message);
		}
		return Global.app.getString(R.string.second_help_message);
	}
}